home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / xpcom / nsIUnicharInputStream.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  9KB  |  220 lines

  1. /*
  2.  * DO NOT EDIT.  THIS FILE IS GENERATED FROM nsIUnicharInputStream.idl
  3.  */
  4.  
  5. #ifndef __gen_nsIUnicharInputStream_h__
  6. #define __gen_nsIUnicharInputStream_h__
  7.  
  8.  
  9. #ifndef __gen_nsISupports_h__
  10. #include "nsISupports.h"
  11. #endif
  12.  
  13. /* For IDL files that don't want to include root IDL files. */
  14. #ifndef NS_NO_VTABLE
  15. #define NS_NO_VTABLE
  16. #endif
  17. class nsIUnicharInputStream; /* forward declaration */
  18.  
  19. /**
  20.  * The signature of the writer function passed to ReadSegments. This
  21.  * is the "consumer" of data that gets read from the stream's buffer.
  22.  *
  23.  * @param aInStream stream being read
  24.  * @param aClosure opaque parameter passed to ReadSegments
  25.  * @param aFromSegment pointer to memory owned by the input stream
  26.  * @param aToOffset amount already read (since ReadSegments was called)
  27.  * @param aCount length of fromSegment
  28.  * @param aWriteCount number of bytes read
  29.  *
  30.  * Implementers should return the following:
  31.  *
  32.  * @return NS_OK and (*aWriteCount > 0) if consumed some data
  33.  * @return <any-error> if not interested in consuming any data
  34.  *
  35.  * Errors are never passed to the caller of ReadSegments.
  36.  *
  37.  * NOTE: returning NS_OK and (*aWriteCount = 0) has undefined behavior.
  38.  */
  39. typedef NS_CALLBACK(nsWriteUnicharSegmentFun)(nsIUnicharInputStream *aInStream,
  40.                                               void *aClosure,
  41.                                               const PRUnichar *aFromSegment,
  42.                                               PRUint32 aToOffset,
  43.                                               PRUint32 aCount,
  44.                                               PRUint32 *aWriteCount);
  45.  
  46. /* starting interface:    nsIUnicharInputStream */
  47. #define NS_IUNICHARINPUTSTREAM_IID_STR "d5e3bd80-6723-4b92-b0c9-22f6162fd94f"
  48.  
  49. #define NS_IUNICHARINPUTSTREAM_IID \
  50.   {0xd5e3bd80, 0x6723, 0x4b92, \
  51.     { 0xb0, 0xc9, 0x22, 0xf6, 0x16, 0x2f, 0xd9, 0x4f }}
  52.  
  53. class NS_NO_VTABLE nsIUnicharInputStream : public nsISupports {
  54.  public: 
  55.  
  56.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IUNICHARINPUTSTREAM_IID)
  57.  
  58.   /**
  59.  * Abstract unicode character input stream
  60.  * @see nsIInputStream
  61.  */
  62. /**
  63.    * Reads into a caller-provided character array.
  64.    *
  65.    * @return The number of characters that were successfully read. May be less
  66.    *         than aCount, even if there is more data in the input stream.
  67.    *         A return value of 0 means EOF.
  68.    *
  69.    * @note To read more than 2^32 characters, call this method multiple times.
  70.    */
  71.   /* [noscript] unsigned long read ([array, size_is (aCount)] in PRUnichar aBuf, in unsigned long aCount); */
  72.   NS_IMETHOD Read(PRUnichar *aBuf, PRUint32 aCount, PRUint32 *_retval) = 0;
  73.  
  74.   /**
  75.    * Low-level read method that has access to the stream's underlying buffer.
  76.    * The writer function may be called multiple times for segmented buffers.
  77.    * ReadSegments is expected to keep calling the writer until either there is
  78.    * nothing left to read or the writer returns an error.  ReadSegments should
  79.    * not call the writer with zero characters to consume.
  80.    *
  81.    * @param aWriter the "consumer" of the data to be read
  82.    * @param aClosure opaque parameter passed to writer 
  83.    * @param aCount the maximum number of characters to be read
  84.    *
  85.    * @return number of characters read (may be less than aCount)
  86.    * @return 0 if reached end of file (or if aWriter refused to consume data)
  87.    *
  88.    * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream would
  89.    *   block the calling thread (non-blocking mode only)
  90.    * @throws <other-error> on failure
  91.    *
  92.    * NOTE: this function may be unimplemented if a stream has no underlying
  93.    * buffer
  94.    */
  95.   /* [noscript] unsigned long readSegments (in nsWriteUnicharSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount); */
  96.   NS_IMETHOD ReadSegments(nsWriteUnicharSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) = 0;
  97.  
  98.   /**
  99.    * Read into a string object.
  100.    * @param aCount The number of characters that should be read
  101.    * @return The number of characters that were read.
  102.    */
  103.   /* unsigned long readString (in unsigned long aCount, out AString aString); */
  104.   NS_IMETHOD ReadString(PRUint32 aCount, nsAString & aString, PRUint32 *_retval) = 0;
  105.  
  106.   /**
  107.   * Close the stream and free associated resources. This also closes the
  108.   * underlying stream, if any.
  109.   */
  110.   /* void close (); */
  111.   NS_IMETHOD Close(void) = 0;
  112.  
  113. };
  114.  
  115. /* Use this macro when declaring classes that implement this interface. */
  116. #define NS_DECL_NSIUNICHARINPUTSTREAM \
  117.   NS_IMETHOD Read(PRUnichar *aBuf, PRUint32 aCount, PRUint32 *_retval); \
  118.   NS_IMETHOD ReadSegments(nsWriteUnicharSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval); \
  119.   NS_IMETHOD ReadString(PRUint32 aCount, nsAString & aString, PRUint32 *_retval); \
  120.   NS_IMETHOD Close(void); 
  121.  
  122. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  123. #define NS_FORWARD_NSIUNICHARINPUTSTREAM(_to) \
  124.   NS_IMETHOD Read(PRUnichar *aBuf, PRUint32 aCount, PRUint32 *_retval) { return _to Read(aBuf, aCount, _retval); } \
  125.   NS_IMETHOD ReadSegments(nsWriteUnicharSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return _to ReadSegments(aWriter, aClosure, aCount, _retval); } \
  126.   NS_IMETHOD ReadString(PRUint32 aCount, nsAString & aString, PRUint32 *_retval) { return _to ReadString(aCount, aString, _retval); } \
  127.   NS_IMETHOD Close(void) { return _to Close(); } 
  128.  
  129. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  130. #define NS_FORWARD_SAFE_NSIUNICHARINPUTSTREAM(_to) \
  131.   NS_IMETHOD Read(PRUnichar *aBuf, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Read(aBuf, aCount, _retval); } \
  132.   NS_IMETHOD ReadSegments(nsWriteUnicharSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->ReadSegments(aWriter, aClosure, aCount, _retval); } \
  133.   NS_IMETHOD ReadString(PRUint32 aCount, nsAString & aString, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->ReadString(aCount, aString, _retval); } \
  134.   NS_IMETHOD Close(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Close(); } 
  135.  
  136. #if 0
  137. /* Use the code below as a template for the implementation class for this interface. */
  138.  
  139. /* Header file */
  140. class nsUnicharInputStream : public nsIUnicharInputStream
  141. {
  142. public:
  143.   NS_DECL_ISUPPORTS
  144.   NS_DECL_NSIUNICHARINPUTSTREAM
  145.  
  146.   nsUnicharInputStream();
  147.  
  148. private:
  149.   ~nsUnicharInputStream();
  150.  
  151. protected:
  152.   /* additional members */
  153. };
  154.  
  155. /* Implementation file */
  156. NS_IMPL_ISUPPORTS1(nsUnicharInputStream, nsIUnicharInputStream)
  157.  
  158. nsUnicharInputStream::nsUnicharInputStream()
  159. {
  160.   /* member initializers and constructor code */
  161. }
  162.  
  163. nsUnicharInputStream::~nsUnicharInputStream()
  164. {
  165.   /* destructor code */
  166. }
  167.  
  168. /* [noscript] unsigned long read ([array, size_is (aCount)] in PRUnichar aBuf, in unsigned long aCount); */
  169. NS_IMETHODIMP nsUnicharInputStream::Read(PRUnichar *aBuf, PRUint32 aCount, PRUint32 *_retval)
  170. {
  171.     return NS_ERROR_NOT_IMPLEMENTED;
  172. }
  173.  
  174. /* [noscript] unsigned long readSegments (in nsWriteUnicharSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount); */
  175. NS_IMETHODIMP nsUnicharInputStream::ReadSegments(nsWriteUnicharSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval)
  176. {
  177.     return NS_ERROR_NOT_IMPLEMENTED;
  178. }
  179.  
  180. /* unsigned long readString (in unsigned long aCount, out AString aString); */
  181. NS_IMETHODIMP nsUnicharInputStream::ReadString(PRUint32 aCount, nsAString & aString, PRUint32 *_retval)
  182. {
  183.     return NS_ERROR_NOT_IMPLEMENTED;
  184. }
  185.  
  186. /* void close (); */
  187. NS_IMETHODIMP nsUnicharInputStream::Close()
  188. {
  189.     return NS_ERROR_NOT_IMPLEMENTED;
  190. }
  191.  
  192. /* End of implementation class template. */
  193. #endif
  194.  
  195. #include "nsStringFwd.h"
  196. class nsIInputStream;
  197. /**
  198.  * Create a nsIUnicharInputStream that wraps up a string. Data is fed
  199.  * from the string out until the done. When this object is destroyed
  200.  * it destroys the string by calling |delete| on the pointer if
  201.  * aTakeOwnership is set.  If aTakeOwnership is not set, you must
  202.  * ensure that the string outlives the stream!
  203.  */
  204. extern NS_COM nsresult
  205.   NS_NewStringUnicharInputStream(nsIUnicharInputStream** aInstancePtrResult,
  206.                                  const nsAString* aString,
  207.                                  PRBool aTakeOwnership);
  208. /**
  209.  * Create a new nsUnicharInputStream that provides a converter for the
  210.  * byte input stream aStreamToWrap. If no converter can be found then
  211.  * nsnull is returned and the error code is set to
  212.  * NS_INPUTSTREAM_NO_CONVERTER.
  213.  */
  214. extern NS_COM nsresult
  215.   NS_NewUTF8ConverterStream(nsIUnicharInputStream** aInstancePtrResult,
  216.                             nsIInputStream* aStreamToWrap,
  217.                             PRInt32 aBufferSize = 0);
  218.  
  219. #endif /* __gen_nsIUnicharInputStream_h__ */
  220.